//
//  MainViewController.m
//  PerfectWorld
//
//  Created by dllo on 16/8/27.
//  Copyright © 2016年 LST. All rights reserved.
//

#import "MainViewController.h"
#import "DecorateViewController.h"
#import "FitmentViewController.h"
#import "MapDepotViewController.h"
#import "StylistViewController.h"
@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatTabBar];
}
- (void)creatTabBar {
    DecorateViewController *homeVC = [[DecorateViewController alloc] init];
    FitmentViewController *findVC = [[FitmentViewController alloc] init];
    MapDepotViewController *rankVC = [[MapDepotViewController alloc] init];
    StylistViewController *mineVC = [[StylistViewController alloc] init];
    [self addChildVC:homeVC Title:@"装修案例" Image:@"房子1" SeleImage:@"房子2"];
    [self addChildVC:findVC Title:@"图库" Image:@"图片1" SeleImage:@"图片2"];
    [self addChildVC:rankVC Title:@"装修攻略" Image:@"攻略1" SeleImage:@"攻略2"];
    [self addChildVC:mineVC Title:@"设计师" Image:@"设计1" SeleImage:@"设计2"];
  
}

-(void)addChildVC:(UIViewController *)childVC
            Title:(NSString *)title
            Image:(NSString *)image
        SeleImage:(NSString *)seleImage{
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childVC];
    childVC.title = title;
    childVC.tabBarItem.image = [UIImage imageNamed:image];
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:seleImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
    bgView.backgroundColor = [UIColor whiteColor];
    [self.tabBar insertSubview:bgView atIndex:0];
    self.tabBar.opaque = YES;
    // 取消文字的渲染蓝色效果
    NSMutableDictionary *dicOne = [NSMutableDictionary dictionary];
    dicOne[NSForegroundColorAttributeName] = [UIColor colorWithRed:0.50 green:0.75 blue:0.92 alpha:1.00];
    NSMutableDictionary *dicTwo = [NSMutableDictionary dictionary];
    dicTwo[NSForegroundColorAttributeName] = [UIColor colorWithRed:0.50 green:0.75 blue:0.92 alpha:1.00];
    [childVC.tabBarItem setTitleTextAttributes:dicOne forState:UIControlStateNormal];
    [childVC.tabBarItem setTitleTextAttributes:dicTwo forState:UIControlStateSelected];
    [self addChildViewController:nav];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
